<?php

class Solution
{

    /**
     * @param Integer[] $nums
     * @param Integer   $target
     * @return Integer[]
     */
    function searchRange($nums, $target)
    {
        $str = '|' . implode('|', $nums) . '|';
        $firstIndex = strpos($str, '|' . $target . '|');
        if ($firstIndex === false) {
            return [-1, -1];
        }
        $lastIndex = strripos($str, '|' . $target . '|');

        $subStrFirst = substr($str, 0, $firstIndex);

        $subStrLast = substr($str, 0, $lastIndex);

        return [substr_count($subStrFirst, '|'), substr_count($subStrLast, '|')];
    }
}
